package com.wao.cms.service.mapper;

import com.wao.cms.domain.*;
import com.wao.cms.service.dto.TemplatePropertyDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity TemplateProperty and its DTO TemplatePropertyDTO.
 */
@Mapper(componentModel = "spring", uses = {TemplateMapper.class, MaterialMapper.class, })
public interface TemplatePropertyMapper extends EntityMapper <TemplatePropertyDTO, TemplateProperty> {

    @Mapping(source = "template.id", target = "templateId")
    @Mapping(source = "template.name", target = "templateName")

    @Mapping(source = "material.id", target = "materialId")
    @Mapping(source = "material.name", target = "materialName")
    TemplatePropertyDTO toDto(TemplateProperty templateProperty); 

    @Mapping(source = "templateId", target = "template")

    @Mapping(source = "materialId", target = "material")
    TemplateProperty toEntity(TemplatePropertyDTO templatePropertyDTO); 
    default TemplateProperty fromId(Long id) {
        if (id == null) {
            return null;
        }
        TemplateProperty templateProperty = new TemplateProperty();
        templateProperty.setId(id);
        return templateProperty;
    }
}
